<template>
	<view class="content">
		<scroll-view scroll-y="true" >
			<view class="row radioList" v-for="(item,index) in infoList" :key="index" @click="changeRadio(index)">
				<view class="col-20">
					<view class="row">
						<view class="col-24 name t_size_33">
							{{item.name}}<text class="t_size_24" v-if="item.isOneself">本人</text>
						</view>
						<view class="col-24 phone t_size_28">
							{{item.mobile}}
						</view>
					</view>
				</view>
				<view class="col-4 radio t_right">
					<image src="../../../static/trip/yjt@2x.png" mode="heightFix"></image>
				</view>
			</view>
		</scroll-view>
		<view class="btn">
			<button type="primary" @click="$public.navTo('trip/cj/cj_rider_add')">添加新地址</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {
					"pageNum": 0,
					"pageSize": 10,
					// "userId": uni.getStorageSync('userInfo').id
				},
				infoList:[],
				loading: true
			}
		},
		onLoad(option) {
			this.load()
		},
		methods: {
			async load() {
				if(!this.loading){
					return
				}
				let res = await this.$api.request(this.$api.user.getlist, this.info);
				if(res){
					this.infoList = this.infoList.concat(res.list);
					this.info.pageNum += 1;
					if(res.length != this.info.pageSize){
						this.loading = false;
					}
				}
			},
			changeRadio(value){
				let obj = {
					name: this.infoList[value].name,
					phone: this.infoList[value].mobile
				}
				uni.setStorageSync('objContacts',obj);
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F5F5F5;
	}

	.content {
		padding: 21rpx 0;
		padding-bottom: 118rpx;
	}

	scroll-view{
		max-height: calc(100vh - 139rpx);
	}

	.radioList {
		width: 92%;
		padding: 21rpx 4%;
		background-color: #FFFFFF;
		border-bottom: 1px solid #ededed;

		.name {
			color: #333333;
			height: 55rpx;
			line-height: 55rpx;

			text {
				color: #6CBF30;
				border: 1px solid #6CBF30;
				margin-left: 11rpx;
				padding: 3rpx 9rpx;
			}
		}

		.phone {
			color: #999999;
			height: 45rpx;
			line-height: 45rpx;
		}

		.radio {
			height: 100rpx;
			image{
				height: 30rpx;
				margin-top: 35rpx;
			}
		}
	}

	.btn {
		background-color: #FFFFFF;
		width: 92%;
		padding: 11rpx 4%;
		position: fixed;
		left: 0;
		bottom: 0;

		button {
			height: 96rpx;
			line-height: 96rpx;
			border-radius: 48rpx;
			background-color: #6CBF30;
		}
	}
</style>
